//***********************************************************************
//	File:		TileSystem.cpp
//	Author:		Ryan Simmons
//	Course:		SGP 1405
//	Purpose:	Handles all information regarding tiles, their collision,
//				rendering, and pathfinding
//***********************************************************************
//***********************************************************************
//	Purposfully left blank for all comments regarding this file 
//	
//	
//	
//***********************************************************************
#include "TileSystem.h"

#include "../GameObjects/Entity.h"

#include "../Message/CreateEntityMessage.h"

#include "../SGD Wrappers/SGD_Geometry.h"
#include "../SGD Wrappers/SGD_GraphicsManager.h"

#include "../TinyXML/tinyxml.h"

#include "../GameStates/Play.h"
#include "../source/Game.h"

#include <queue>
#include <sstream>

/**************************************************************/
// GetInstance
//	- store the ONLY instance in global memory
//	- return the only instance by pointer
TileSystem*			TileSystem::GetInstance ( void )
{
	static TileSystem s_Instance;

	return &s_Instance;
}

/**************************************************************/
// Render
// - Iterates through all layers and renders all tiles on each
//	 layer in order;
void				TileSystem::Render ( void ) const
{
	// Grab the viewing area
	SGD::Rectangle camera = Play::GetInstance ()->GetCameraRect ();

	// Get the width and height of a single tile
	int width = TILESYSTEM->GetTileSize ().m_nWidth;
	int height = TILESYSTEM->GetTileSize ().m_nHeight;

	// Get the map size in number of tiles
	int mapWidth = TILESYSTEM->GetMapSize ().m_nWidth;
	int mapHeight = TILESYSTEM->GetMapSize ().m_nHeight;

	// Calculate left bounds
	int left = (int)((camera.left - width) / width);
	if ( left < 0 )
		left = 0;

	// Calculate right bounds
	int right = (int)((camera.right + width) / width);
	if ( right > mapWidth )
		right = mapWidth;

	// Calculate top bounds
	int top = (int)((camera.top - height) / height);
	if ( top < 0 )
		top = 0;

	// Calculate bottom bounds
	int bottom = (int)((camera.bottom + height) / height);
	if ( bottom > mapHeight )
		bottom = mapHeight;

	// Render only the tiles that are in the viewing area
	for ( unsigned int l = 0; l < LAYERS.size (); l++ )
	{
		for ( int w = left; w < right; w++ )
		{
			for ( int h = top; h < bottom; h++ )
			{
				LAYERS[ l ].m_vTiles[ w ][ h ]->Render ();
			}

		}
	}
}

/**************************************************************/
// CheckWorld
// - Ensures the location you are trying to move to will not be
// on an impassable tile
SGD::Rectangle		TileSystem::CheckWorld ( const SGD::Rectangle obj )
{

	// Set the no collision return value
	SGD::Rectangle collision = SGD::Rectangle(0.0f, 0.0f, 0.0f, 0.0f);

	// Grab the width and height of a single tile
	int width = TILESYSTEM->GetTileSize ().m_nWidth;
	int height = TILESYSTEM->GetTileSize ().m_nHeight;

	// Grab the map size in number of tiles
	int mapWidth = TILESYSTEM->GetMapSize ().m_nWidth;
	int mapHeight = TILESYSTEM->GetMapSize ().m_nHeight;

	// Calculate left bounds
	int left = (int)((obj.left - width) / width);
	if ( left < 0 )
		left = 0;

	// Calculate right bounds
	int right = (int)((obj.right + width) / width);
	if ( right > mapWidth )
		right = mapWidth;

	// Calculate top bounds
	int top = (int)((obj.top - height) / height);
	if ( top < 0 )
		top = 0;

	// Calculate bottom bounds
	int bottom = (int)((obj.bottom + height) / height);
	if ( bottom > mapHeight )
		bottom = mapHeight;

	for ( unsigned int l = 0; l < LAYERS.size (); l++ )
	{
		for ( int w = left; w < right; w++ )
		{
			for ( int h = top; h < bottom; h++ )
			{
				// If the object is interescting with this tile
				if ( obj.IsIntersecting (LAYERS[ l ].m_vTiles[ w ][ h ]->GetRect () ) )
				{
					// Spawn the trigger group the tile is associated with if it is ( if it's trigger group isn't -1 ) and if that group has not been spawned yet
					if ( LAYERS[l].m_vTiles[w][h]->GetTrigger() != -1 && m_sgGroups[ LAYERS[ l ].m_vTiles[ w ][ h ]->GetTrigger () ].m_bHasSpawned == false )
					{
						TriggerGroupSpawn ( LAYERS[ l ].m_vTiles[ w ][ h ]->GetTrigger () );
					}
					// If the tile is not passible set the collision to this tile... all other tiles it is colliding with will trigger but only the first will be set
					if ( LAYERS[ l ].m_vTiles[ w ][ h ]->IsPassable () == false )
					{
						if(collision.left == 0.0f && collision.top == 0.0f && collision.right == 0.0f && collision.bottom == 0.0f)
						collision = LAYERS[ l ].m_vTiles[ w ][ h ]->GetRect ();
					}
				}
			}
		}
	}
	return collision;
}

/**************************************************************/
// GetTileSet
//	- Returns the handle to the corresponding image based on the setID
TileSystem::TileSet	TileSystem::GetTileSet ( unsigned int setID ) const
{
	return m_vTileSets[ setID ];
}

/**************************************************************/
// GetLayers
// - Returns the vector of layers
DynArray<Layer>		TileSystem::GetLayers ( void ) const
{
	return m_vLayers;
}

/**************************************************************/
// GetSection
//	- Returns the render rectangle of the image based on the tileID
SGD::Rectangle		TileSystem::GetSection ( unsigned int tileID , unsigned int setID ) const
{
	SGD::Rectangle section;

	section.left = (float)((tileID % TILESYSTEM->GetTileSet ( setID ).m_szSize.m_nWidth) * TILESYSTEM->GetTileSize ().m_nWidth);
	section.top = (float)((tileID / TILESYSTEM->GetTileSet ( setID ).m_szSize.m_nWidth) * TILESYSTEM->GetTileSize ().m_nHeight);

	section.right = section.left + TILESYSTEM->GetTileSize ().m_nWidth;
	section.bottom = section.top + TILESYSTEM->GetTileSize ().m_nHeight;

	return section;
}

/**************************************************************/
// GetMapSize
//	- Returns how many tiles wide and high the current map is
TileSystem::Size	TileSystem::GetMapSize () const
{
	return m_szMapWH;
}

/**************************************************************/
// GetTileSize
//	- Returns the width and height of each individual tile
TileSystem::Size	TileSystem::GetTileSize () const
{
	return m_szTileWH;
}

/**************************************************************/
// GetRenderPoint
//	- Tile sends its point in and is returned its render location
SGD::Point			TileSystem::GetRenderPoint ( SGD::Point p ) const
{
	SGD::Point renderP;

	renderP.x = p.x - Play::GetInstance ()->GetCameraPos ().x;
	renderP.y = p.y - Play::GetInstance ()->GetCameraPos ().y;

	return renderP;
}

/**************************************************************/
// LoadLevel
// - Parses the XML and loads the level
bool				TileSystem::LoadLevel ( const char * filepath )
{
	if(m_bLoaded == true)
		return false;

	SGD::GraphicsManager * pGraphics = SGD::GraphicsManager::GetInstance ();

	if ( pGraphics == nullptr )
		pGraphics->Initialize ();

	int xDraw = (int)Game::GetInstance ()->GetScreenWidth ();
	int yDraw = (int)Game::GetInstance ()->GetScreenWidth ();
	xDraw /= 2;
	yDraw /= 2;
	Game::GetInstance ()->GetFont ()->Draw ( "Loading Level" , xDraw , yDraw , 1.0f , SGD::Color ( 255 , 255 , 255 , 255 ) );


	//Create a TinyXML Document
	TiXmlDocument doc;

	// Load the file
	if ( doc.LoadFile ( filepath ) == false )
		return false;

	TiXmlElement* pRoot = doc.RootElement ();

	if ( pRoot == nullptr )
		return false;


	// Find MapSize element
	TiXmlElement* pInfo = pRoot->FirstChildElement ( "MapSize" );

	// Set values for failure test
	m_szMapWH.m_nWidth = -1;
	m_szMapWH.m_nHeight = -1;

	// Load map width and height
	if ( pInfo != nullptr )
	{
		pInfo->Attribute ( "width" , &m_szMapWH.m_nWidth );
		pInfo->Attribute ( "height" , &m_szMapWH.m_nHeight );

		// Check for failure
		if ( -1 == m_szMapWH.m_nWidth || -1 == m_szMapWH.m_nHeight )
			return false;
	}
	else
		return false;

	// Find TileSize element
	pInfo = pInfo->NextSiblingElement ( "TileSize" );

	// Set values for failure test
	m_szTileWH.m_nWidth = -1;
	m_szTileWH.m_nHeight = -1;

	// Load tile width and height
	if ( pInfo != nullptr )
	{
		pInfo->Attribute ( "width" , &m_szTileWH.m_nWidth );
		pInfo->Attribute ( "height" , &m_szTileWH.m_nHeight );

		// Check for failure
		if ( -1 == m_szTileWH.m_nWidth || -1 == m_szTileWH.m_nHeight )
			return false;
	}
	else
		return false;

	// Find number of Tile Set Images
	pInfo = pInfo->NextSiblingElement ( "NumberTileSets" );

	//Store number of images
	int m_nNumSets = 0;

	if ( pInfo != nullptr )
	{
		pInfo->Attribute ( "number" , &m_nNumSets );

		// Check for failure
		if ( 0 == m_nNumSets )
			return false;
		m_vTileSets.reserve ( m_nNumSets );
	}
	else
		return false;

	for ( int i = 0; i < m_nNumSets; i++ )
	{
		// Find the next TileSetImage
		pInfo = pInfo->NextSiblingElement ( "TileSetImage" );

		if ( pInfo != nullptr )
		{
			m_vTileSets.append ( TileSet () );
			// Setup failure check
			m_vTileSets[ i ].m_hImage = SGD::INVALID_HANDLE;

			// Set image
			std::string img = "resource/graphics/" + (std::string)pInfo->GetText ();
			m_vTileSets[ i ].m_hImage = pGraphics->LoadTexture ( img.c_str () );

			// Check for failure
			if ( m_vTileSets[ i ].m_hImage == SGD::INVALID_HANDLE )
				return false;

			pInfo->Attribute ( "width" , &m_vTileSets[ i ].m_szSize.m_nWidth );
			pInfo->Attribute ( "height" , &m_vTileSets[ i ].m_szSize.m_nHeight );
		}
		else
			return false;
	}

	// Find number of Tile Set Images
	pInfo = pInfo->NextSiblingElement ( "NumberLayers" );

	//Store number of images
	int m_nNumLayers = 0;

	if ( pInfo != nullptr )
	{
		pInfo->Attribute ( "number" , &m_nNumLayers );

		// Check for failure
		if ( 0 == m_nNumLayers )
			return false;
		m_vLayers.reserve ( m_nNumLayers );
		for ( int i = 0; i < m_nNumLayers; i++ )
		{
			m_vLayers.append ( Layer () );
		}
	}
	else
		return false;

	// Get the first layer
	TiXmlElement* pLayer = pInfo->FirstChildElement ( "Layer" );

	// For each layer
	for ( int l = 0; l < m_nNumLayers; l++ )
	{
		// Find the first tile
		TiXmlElement* pTile = pLayer->FirstChildElement ( "Tile" );

		// Reserve the number of tiles wide for the breadth
		m_vLayers[ l ].m_vTiles.reserve ( m_szMapWH.m_nWidth );
		for ( int w = 0; w < m_szMapWH.m_nWidth; w++ )
		{
			DynArray<Tile *> tempV;
			m_vLayers[ l ].m_vTiles.append ( tempV );
			m_vLayers[ l ].m_vTiles[ w ].reserve ( m_szMapWH.m_nHeight );
			for ( int h = 0; h < m_szMapWH.m_nHeight; h++ )
			{

				// Parse all the variables
				int tileID , setID , pass , trig;
				double dX , dY;

				pTile->Attribute ( "XLoc" , &dX );
				pTile->Attribute ( "YLoc" , &dY );
				pTile->Attribute ( "TileID" , &tileID );
				pTile->Attribute ( "SetID" , &setID );
				pTile->Attribute ( "Passable" , &pass );
				pTile->Attribute ( "Trigger" , &trig );


				SGD::Point loc ( (float)dX , (float)dY );
				bool isPass = false;
				if ( pass == 1 )
					isPass = true;

				Tile* temp = new Tile ( loc , tileID , setID , trig , isPass );

				// Create the new tile with the parsed information and push it into the layer
				m_vLayers[ l ].m_vTiles[ w ].append ( temp );

				pTile = pTile->NextSiblingElement ( "Tile" );
				if ( pTile == nullptr )
					break;
			}
		}
		// Go to the next layer
		if(l != m_nNumLayers - 1)
		pLayer = pLayer->NextSiblingElement ( "Layer" );
	}

	// Get the player spawn location
	pInfo = pInfo->NextSiblingElement ( "PlayerSpawn" );
	int x , y;
	pInfo->Attribute ( "XLoc" , &x );
	pInfo->Attribute ( "YLoc" , &y );
	m_ptPlayerSpawn.x = (float)x;
	m_ptPlayerSpawn.y = (float)y;

	// Create the number of trigger groups to be used in the level
	pInfo = pInfo->NextSiblingElement ( "Groups" );
	int	m_nNumGroups = 0;
	if ( pInfo != nullptr )
	{
		

		pInfo->Attribute ( "Quantity" , &m_nNumGroups );

		for ( int i = 0; i < m_nNumGroups; i++ )
		{
			m_sgGroups.append ( SpawnGroup () );
		}
	}
	else
		return false;

	// Get the first group in the list
	TiXmlElement* pGroup = pInfo->FirstChildElement ( "Group" );


	for ( int i = 0; i < m_nNumGroups; i++ )
	{
		int numEnts = 0;
		pGroup->Attribute ( "Quantity" , &numEnts );
		if ( numEnts > 0 )
		{
			TiXmlElement* pEnemy = pGroup->FirstChildElement ( "Entity" );
			for ( int j = 0; j < numEnts; j++ )
			{
				int xloc , yloc , group;
				EnemyShell temp;
				pEnemy->Attribute ( "XLoc" , &xloc );
				pEnemy->Attribute ( "YLoc" , &yloc );
				pEnemy->Attribute ( "Type" , &temp.m_nType );
				pEnemy->Attribute ( "Group" , &group );

				temp.m_ptLoc.x = (float)xloc;
				temp.m_ptLoc.y = (float)yloc;

				m_sgGroups[ group ].m_eEnemies.append ( temp );

				pEnemy = pEnemy->NextSiblingElement ( "Entity" );
			}
		}
		pGroup = pGroup->NextSiblingElement ( "Group" );
	}

	m_bLoaded = true;
	return true;
}

/**************************************************************/
// UnloadLevel
// - Releases all assets and memory being used by the tile system
void				TileSystem::UnloadLevel ( void )
{
	for ( unsigned int l = 0; l < m_vLayers.size (); l++ )
	{
		for ( int w = 0; w < m_szMapWH.m_nWidth; w++ )
		{
			for ( int h = 0; h < m_szMapWH.m_nHeight; h++ )
			{
				delete m_vLayers[ l ].m_vTiles[ w ][ h ];
			}
		}
	}
	m_vLayers.clear ();
	for ( unsigned int i = 0; i < m_vTileSets.size (); i++ )
	{
		SGD::GraphicsManager::GetInstance ()->UnloadTexture ( m_vTileSets[ i ].m_hImage );
	}
	m_vTileSets.clear ();
	m_sgGroups.clear ();
	m_bLoaded = false;
}

/**************************************************************/
// TriggerGroupSpawn
// - Sends the game a message to spawn all of the enemies in the group
// and sets the group to spawned so it will not spawn again
void				TileSystem::TriggerGroupSpawn ( unsigned int group )
{
	// Make sure the group that is sent is actually in the level
	if ( group < m_sgGroups.size () && group >= 0 )
	{
		// Make sure the group has not already been spawned
		if ( m_sgGroups[ group ].m_bHasSpawned == false )
		{
			// Let the tilesystem know it has been spawned now
			m_sgGroups[ group ].m_bHasSpawned = true;

			// Send the create entity messages for each entity in the group
			for ( unsigned int i = 0; i < m_sgGroups[ group ].m_eEnemies.size (); i++ )
			{
				CreateEntityMessage * pMsg = new CreateEntityMessage ( m_sgGroups[ group ].m_eEnemies[ i ].m_nType , m_sgGroups[ group ].m_eEnemies[ i ].m_ptLoc );
				pMsg->QueueMessage ();
				pMsg = nullptr;
			}
		}
	}
}

/**************************************************************/
// GetPath
// - Returns a normalized vector in the direction of which the object
// who calls the function needs to head to get the destination unimpeeded
// by non passable tiles
SGD::Vector			TileSystem::GetPath ( Entity* ent , SGD::Point destination )
{
	SGD::Vector direction = SGD::Vector ( 0.0f , 0.0f );
	SGD::Rectangle obj = ent->GetRect ();

	int width = TILESYSTEM->GetTileSize ().m_nWidth;
	int height = TILESYSTEM->GetTileSize ().m_nHeight;

	int mapWidth = TILESYSTEM->GetMapSize ().m_nWidth;
	int mapHeight = TILESYSTEM->GetMapSize ().m_nHeight;

	// Calculate left bounds
	int left = (int)((obj.left - width) / width);
	if ( left < 0 )
		left = 0;

	// Calculate right bounds
	int right = (int)((obj.right + width) / width);
	if ( right > mapWidth )
		right = mapWidth;

	// Calculate top bounds
	int top = (int)((obj.top - height) / height);
	if ( top < 0 )
		top = 0;

	// Calculate bottom bounds
	int bottom = (int)((obj.bottom + height) / height);
	if ( bottom > mapHeight )
		bottom = mapHeight;

	int endX = 0;
	int endY = 0;

	// Find the tile on your upper most top left that you are standing on as a reference
	for ( unsigned int l = 0; l < LAYERS.size (); l++ )
	{
		for ( int w = left; w < right; w++ )
		{
			for ( int h = top; h < bottom; h++ )
			{
				if ( obj.IsIntersecting ( LAYERS[ l ].m_vTiles[ w ][ h ]->GetRect () ) )
				{
					endX = w;
					endY = h;
					break;
				}
			}
		}
	}

	// Find the upper left most tile the target is standing on
	int startX = (int)((destination.x / width));
	int startY = (int)((destination.y / height));

	// Initialize an empty map of 15 tiles up, down, left, and right of the target destinations tile
	// Will be used as reference to tiles passability
	int collisionMapA[ 31 ][ 31 ] =
	{
		/* 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29  30*/
		/*0*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*1*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*2*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*3*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*4*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*5*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*6*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*7*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*8*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*9*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*10*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*11*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*12*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*13*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*14*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*15*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*16*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*17*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*18*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*19*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*20*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*21*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*22*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*23*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*24*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*25*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*26*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*27*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*28*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*29*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*30*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,

	};

	// This map will correspond to the previous map but will hold the number of steps it takes to get to that tile. will remain -1 if it is unpassable
	int collisionMapB[ 31 ][ 31 ] =
	{
		/* 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29  30*/
		/*0*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*1*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*2*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*3*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*4*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*5*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*6*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*7*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*8*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*9*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*10*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*11*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*12*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*13*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*14*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*15*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*16*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*17*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*18*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*19*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*20*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*21*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*22*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*23*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*24*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*25*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*26*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*27*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*28*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*29*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,
		/*30*/ { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 } ,

	};

	int traverseX = 0;
	int traverseY = 0;

	// Assign 1's for passable and 0's for impassable to Map A
	for ( int w = startX - 15; w < startX + 15; w++ )
	{
		traverseY = 0;
		for ( int h = startX - 15; h < startY + 15; h++ )
		{
			if ( w < mapWidth && w >= 0 && h < mapHeight && h >= 0 )
			{
				if ( LAYERS[ 0 ].m_vTiles[ w ][ h ]->IsPassable () == true )
					collisionMapA[ traverseX ][ traverseY ] = 1;
				else
					collisionMapA[ traverseX ][ traverseY ] = 0;
			}
			traverseY++;
		}
		traverseX++;
	}

	traverseX = 0;
	traverseY = 0;
	struct Stepper
	{
		int x , y , steps;
	};
	std::queue<Stepper> spots;
	collisionMapB[ 15 ][ 15 ] = 0;

	// Que the center spot where your target is
	spots.push ( { 15 , 15 , 0 } );

	// Proceed to map out all the spots in terms of how many tiles from the starting tile it is
	while ( !spots.empty () )
	{
		// Path left
		if ( spots.front ().x - 1 >= 0 && collisionMapA[ spots.front ().x - 1 ][ spots.front ().y ] == 1 && collisionMapB[ spots.front ().x - 1 ][ spots.front ().y ] == -1 )
		{
			spots.push ( { spots.front ().x - 1 , spots.front ().y , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x - 1 ][ spots.front ().y ] = spots.front ().steps + 1;
		}

		// Path right
		if ( spots.front ().x + 1 < 31 && collisionMapA[ spots.front ().x + 1 ][ spots.front ().y ] == 1 && collisionMapB[ spots.front ().x + 1 ][ spots.front ().y ] == -1 )
		{
			spots.push ( { spots.front ().x + 1 , spots.front ().y , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x + 1 ][ spots.front ().y ] = spots.front ().steps + 1;
		}

		// Path up
		if ( spots.front ().y - 1 >= 0 && collisionMapA[ spots.front ().x ][ spots.front ().y - 1 ] == 1 && collisionMapB[ spots.front ().x ][ spots.front ().y - 1 ] == -1 )
		{
			spots.push ( { spots.front ().x , spots.front ().y - 1 , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x ][ spots.front ().y - 1 ] = spots.front ().steps + 1;
		}

		// Path down
		if ( spots.front ().y + 1 < 31 && collisionMapA[ spots.front ().x ][ spots.front ().y + 1 ] == 1 && collisionMapB[ spots.front ().x ][ spots.front ().y + 1 ] == -1 )
		{
			spots.push ( { spots.front ().x , spots.front ().y + 1 , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x ][ spots.front ().y + 1 ] = spots.front ().steps + 1;
		}

		// Path up left
		if ( spots.front ().x - 1 >= 0 && spots.front ().y - 1 >= 0 && collisionMapA[ spots.front ().x - 1 ][ spots.front ().y - 1 ] == 1 &&
			collisionMapB[ spots.front ().x - 1 ][ spots.front ().y - 1 ] == -1 && collisionMapA[ spots.front ().x - 1 ][ spots.front ().y ] == 1 && collisionMapA[ spots.front ().x ][ spots.front ().y - 1 ] == 1 )
		{
			spots.push ( { spots.front ().x - 1 , spots.front ().y - 1 , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x - 1 ][ spots.front ().y - 1 ] = spots.front ().steps + 1;
		}

		// Path up right
		if ( spots.front ().x + 1 < 31 && spots.front ().y - 1 >= 0 && collisionMapA[ spots.front ().x + 1 ][ spots.front ().y - 1 ] == 1 &&
			collisionMapB[ spots.front ().x + 1 ][ spots.front ().y - 1 ] == -1 && collisionMapA[ spots.front ().x + 1 ][ spots.front ().y ] == 1 && collisionMapA[ spots.front ().x ][ spots.front ().y - 1 ] == 1 )
		{
			spots.push ( { spots.front ().x + 1 , spots.front ().y - 1 , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x + 1 ][ spots.front ().y - 1 ] = spots.front ().steps + 1;
		}

		// Path down left
		if ( spots.front ().x - 1 >= 0 && spots.front ().y + 1 < 31 && collisionMapA[ spots.front ().x - 1 ][ spots.front ().y + 1 ] == 1 &&
			collisionMapB[ spots.front ().x - 1 ][ spots.front ().y + 1 ] == -1 && collisionMapA[ spots.front ().x - 1 ][ spots.front ().y ] == 1 && collisionMapA[ spots.front ().x ][ spots.front ().y + 1 ] == 1 )
		{
			spots.push ( { spots.front ().x - 1 , spots.front ().y + 1 , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x - 1 ][ spots.front ().y + 1 ] = spots.front ().steps + 1;
		}

		// Path down right
		if ( spots.front ().x + 1 < 31 && spots.front ().y + 1 < 31 && collisionMapA[ spots.front ().x + 1 ][ spots.front ().y + 1 ] == 1 &&
			collisionMapB[ spots.front ().x + 1 ][ spots.front ().y + 1 ] == -1 && collisionMapA[ spots.front ().x + 1 ][ spots.front ().y ] == 1 && collisionMapA[ spots.front ().x ][ spots.front ().y + 1 ] == 1 )
		{
			spots.push ( { spots.front ().x + 1 , spots.front ().y + 1 , spots.front ().steps + 1 } );
			collisionMapB[ spots.front ().x + 1 ][ spots.front ().y + 1 ] = spots.front ().steps + 1;
		}

		// Pop the spot because all of its surrounding spots have been pushed in the que to map out their surrounding tiles
		spots.pop ();
	}

	// Find the tile that you are standing in reference to where your target is standing
	int dirX = endX - startX;
	int dirY = endY - startX;

	int originX = dirX + 15;
	int originY = dirY + 15;

	struct Travel
	{
		SGD::Vector dir;
		int steps;

	};
	// Make sure you are within the bounds of your collision map
	if ( originX >= 0 && originX < 31 && originY >= 0 && originY < 31 )
	{
		Travel topL, topM, topR, midL, midR, botL, botM, botR;

		topL.dir = SGD::Vector(-1, -1);
		topL.steps = 10000;
		topM.dir = SGD::Vector(0, -1);
		topM.steps = 10000;
		topR.dir = SGD::Vector(1, -1);
		topR.steps = 10000;
		midL.dir = SGD::Vector(-1, 0);
		midL.steps = 10000;
		midR.dir = SGD::Vector(1, 0);
		midR.steps = 10000;
		botL.dir = SGD::Vector(-1, 1);
		botL.steps = 10000;
		botM.dir = SGD::Vector(0, 1);
		botM.steps = 10000;
		botR.dir = SGD::Vector(1, 1);
		botR.steps = 10000;

		// Up Left
		if(originX - 1 >= 0 && originX - 1 < 31 && originY - 1 >= 0 && originY - 1 < 31 && collisionMapB[originX - 1][originY - 1] != -1)
			topL.steps = collisionMapB[originX -1][originY - 1];
		// Up
		if(originY - 1 >= 0 && originY -1 < 31 && collisionMapB[originX][originY - 1] != -1)
			topM.steps = collisionMapB[originX][originY - 1];
		// Up Right
		if(originX + 1 >= 0 && originX + 1 < 31 && originY + 1 >= 0 && originY - 1 < 31 && collisionMapB[originX + 1][originY - 1] != -1)
			topR.steps = collisionMapB[originX + 1][originY - 1];
		// Left
		if(originX - 1 >= 0 && originX - 1 < 31 && collisionMapB[originX - 1][originY] != -1)
			midL.steps = collisionMapB[originX - 1][originY];
		// Right
		if(originX + 1 >= 0 && originX + 1 < 31 && collisionMapB[originX + 1][originY] != -1)
			midR.steps = collisionMapB[originX + 1][originY];
		// Down Left
		if(originX - 1 >= 0 && originX - 1 < 31 && originY + 1 >= 0 && originY + 1 < 31 && collisionMapB[originX - 1][originY + 1] != -1)
			botL.steps = collisionMapB[originX - 1][originY + 1];
		// Down
		if(originY + 1 >= 0 && originY + 1 < 31 && collisionMapB[originX][originY + 1] != -1)
			botM.steps = collisionMapB[originX][originY + 1];
		// Down Right
		if(originX + 1 >= 0 && originX + 1 < 31 && originY + 1 >= 0 && originY + 1 < 31 && collisionMapB[originX + 1][originY + 1] != -1)
			botR.steps = collisionMapB[originX + 1][originY + 1];

		std::vector<Travel> go;
		go.push_back(topL);
		go.push_back(topM);
		go.push_back(topR);
		go.push_back(midL);
		go.push_back(midR);
		go.push_back(botL);
		go.push_back(botM);
		go.push_back(botR);

		// Sort the possible steps in least to greatest
		sort(go.begin(), go.end(), [](Travel const &l, Travel const& r)
		{
			return l.steps < r.steps;
		});

		// send the shortest distance that is allowed to be traveled
		SGD::Vector rotateTo;
		rotateTo.x = (LAYERS[0].m_vTiles[endX + (int)go[0].dir.x][endY + (int)go[0].dir.y]->GetRect().left);
		rotateTo.y = (LAYERS[0].m_vTiles[endX + (int)go[0].dir.x][endY + (int)go[0].dir.y]->GetRect().top);
		rotateTo.x += (float)(TILESYSTEM->GetTileSize().m_nWidth / 2.0f);
		rotateTo.y += (float)(TILESYSTEM->GetTileSize().m_nHeight / 2.0f);
		return rotateTo;
	}

	return direction;
}

/**************************************************************/
// GetPlayerSpawn
// - Returns the defined location for the player to spawn at the start of the
// loaded level
SGD::Point TileSystem::GetPlayerSpawn( void ) const
{
	return m_ptPlayerSpawn;
}